package com.fds.app.comm.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fds.app.comm.exception.system.ConfigurationException;

@Component
public class TrProcessInvoker {

	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private TrProcessResolver tpProcessResolver;

	/**
	 * 
	 * @param jobCd
	 * @throws ConfigurationException IF jobCd를 처리할 빈이 존재하지 않으면
	 */
	public void invoke(String jobCd) throws ConfigurationException {
		
		TrProcessable trProcessable = tpProcessResolver.getTrProcessable();
		
		logger.info("=======================================================>");
		
		if (trProcessable == null) {
			throw new ConfigurationException();
		}		
		trProcessable.init();

		trProcessable.process();

		trProcessable.finish();

		logger.info("<=======================================================");
		
	}
}
